28 research outputs found
A Web Interface for Matita
This article describes a prototype implementation of a web interface for the
Matita proof assistant. The interface supports all basic functionalities of the
local Gtk interface, but takes advantage of the markup to enrich the document
with several kinds of annotations or active elements. Annotations may have both
a presentational/hypertextual nature, aimed to improve the quality of the proof
script as a human readable document, or a more semantic nature, aimed to help
the system in its processing of the script. The latter kind comprises
information automatically generated by the proof assistant during previous
compilations, and stored to improve the performance of re-executing expensive
operations like disambiguation or automation
Comprehending nulls
The Nested Relational Calculus (NRC) has been an influential high-level query
language, providing power and flexibility while still allowing translation to
standard SQL queries. It has also been used as a basis for language-integrated
query in programming languages such as F#, Scala, and Links. However, SQL's
treatment of incomplete information, using nulls and three-valued logic, is not
compatible with `standard' NRC based on two-valued logic. Nulls are widely used
in practice for incomplete data, but the question of how to accommodate
SQL-style nulls and incomplete information in NRC, or integrate such queries
into a typed programming language, appears not to have been studied thoroughly.
In this paper we consider two approaches: an explicit approach in which option
types are used to represent (possibly) nullable primitive types, and an
implicit approach in which types are treated as possibly-null by default. We
give translations relating the implicit and explicit approaches, discuss
handling nulls in language integration, and sketch extensions of normalization
and conservativity results
A Formalization of SQL with Nulls
SQL is the world's most popular declarative language, forming the basis of
the multi-billion-dollar database industry. Although SQL has been standardized,
the full standard is based on ambiguous natural language rather than formal
specification. Commercial SQL implementations interpret the standard in
different ways, so that, given the same input data, the same query can yield
different results depending on the SQL system it is run on. Even for a
particular system, mechanically checked formalization of all widely-used
features of SQL remains an open problem. The lack of a well-understood formal
semantics makes it very difficult to validate the soundness of database
implementations.
Although formal semantics for fragments of SQL were designed in the past,
they usually did not support set and bag operations, nested subqueries, and,
crucially, null values. Null values complicate SQL's semantics in profound ways
analogous to null pointers or side-effects in other programming languages.
Since certain SQL queries are equivalent in the absence of null values, but
produce different results when applied to tables containing incomplete data,
semantics which ignore null values are able to prove query equivalences that
are unsound in realistic databases.
A formal semantics of SQL supporting all the aforementioned features was only
proposed recently. In this paper, we report about our mechanization of SQL
semantics covering set/bag operations, nested subqueries, and nulls, written
the Coq proof assistant, and describe the validation of key metatheoretic
properties
Strongly Normalizing Higher-Order Relational Queries
Language-integrated query is a powerful programming construct allowing database queries and ordinary program code to interoperate seamlessly and safely. Language-integrated query techniques rely on classical results about monadic comprehension calculi, including the conservativity theorem for nested relational calculus. Conservativity implies that query expressions can freely use nesting and unnesting, yet as long as the query result type is a flat relation, these capabilities do not lead to an increase in expressiveness over flat relational queries. Wong showed how such queries can be translated to SQL via a constructive rewriting algorithm, and Cooper and others advocated higher-order nested relational calculi as a basis for language-integrated queries in functional languages such as Links and F#. However there is no published proof of the central strong normalization property for higher-order nested relational queries: a previous proof attempt does not deal correctly with rewrite rules that duplicate subterms. This paper fills the gap in the literature, explaining the difficulty with a previous proof attempt, and showing how to extend the ??-lifting approach of Lindley and Stark to accommodate duplicating rewrites. We also sketch how to extend the proof to a recently-introduced calculus for heterogeneous queries mixing set and multiset semantics
Query Lifting: Language-integrated query for heterogeneous nested collections
Language-integrated query based on comprehension syntax is a powerful
technique for safe database programming, and provides a basis for advanced
techniques such as query shredding or query flattening that allow efficient
programming with complex nested collections. However, the foundations of these
techniques are lacking: although SQL, the most widely-used database query
language, supports heterogeneous queries that mix set and multiset semantics,
these important capabilities are not supported by known correctness results or
implementations that assume homogeneous collections. In this paper we study
language-integrated query for a heterogeneous query language
that combines set and multiset constructs. We show how
to normalize and translate queries to SQL, and develop a novel approach to
querying heterogeneous nested collections, based on the insight that ``local''
query subexpressions that calculate nested subcollections can be ``lifted'' to
the top level analogously to lambda-lifting for local function definitions.Comment: Full version of ESOP 2021 conference pape
Mixing set and bag semantics
The conservativity theorem for nested relational calculus implies that query
expressions can freely use nesting and unnesting, yet as long as the query
result type is a flat relation, these capabilities do not lead to an increase
in expressiveness over flat relational queries. Moreover, Wong showed how such
queries can be translated to SQL via a constructive rewriting algorithm. While
this result holds for queries over either set or multiset semantics, to the
best of our knowledge, the questions of conservativity and normalization have
not been studied for queries that mix set and bag collections, or provide
duplicate-elimination operations such as SQL's
. In this paper we formalize the problem,
and present partial progress: specifically, we introduce a calculus with both
set and multiset collection types, along with natural mappings from sets to
bags and vice versa, present a set of valid rewrite rules for normalizing such
queries, and give an inductive characterization of a set of queries whose
normal forms can be translated to SQL. We also consider examples that do not
appear straightforward to translate to SQL, illustrating that the relative
expressiveness of flat and nested queries with mixed set and multiset semantics
remains an open question.Comment: DBPL 2019 -- short pape